package com.wangxiang.shop.order.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


import com.wangxiang.common.utils.PageEntity;
import com.wangxiang.shop.order.feign.ManageFeign;
import com.wangxiang.shop.order.feign.MemberFeign;
import com.wangxiang.shop.order.feign.ProductFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wangxiang.shop.order.entity.ShipOrderEntity;
import com.wangxiang.shop.order.service.ShipOrderService;
import com.wangxiang.common.utils.PageUtils;
import com.wangxiang.common.utils.R;



/**
 * 
 *
 * @author wangxiang
 * @email 2293672863@qq.com
 * @date 2022-04-23 16:57:39
 */
@RestController
@RequestMapping("order/ship")
public class ShipOrderController {
    @Autowired
    private ShipOrderService shipOrderService;
    @Autowired
    MemberFeign memberFeign;
    @Autowired
    ProductFeign productFeign;
    @Autowired
    ManageFeign manageFeign;


    @RequestMapping("add")
    public R add(@RequestBody HashMap<String , Integer> map){
        int add = shipOrderService.add(map);
        if (add==0){
            return R.error("发货失败,数据库错误");
        }
        return R.ok().put("msg","你已发货，系统默认商城物流").put("code",800);
    }

    @RequestMapping("page")
    public R page(@RequestBody HashMap<String , Integer> map){
        PageEntity page = shipOrderService.page(map);
        List<HashMap<String, Object>> pageList = shipOrderService.pageList((List<ShipOrderEntity>) page.getList());
        List<HashMap<String, Object>> memberOrderList = productFeign.memberOrderList(pageList);
        List<HashMap<String, Object>> list = memberFeign.memberOrderList(memberOrderList);
        List<HashMap<String, Object>> listHash = manageFeign.orderList(list);
        return R.ok().put("list",listHash).put("page",page);
    }



}
